package Server.network.server;

import Server.Opcodes;
import Server.world.object;

public class Movechar extends BasePacket{
	public Movechar(object cha){
		int x = cha.get_x();
		int y = cha.get_y();
		switch(cha.get_heading()){
			case 0:
				y += 1;
				break;
			case 1:
				x -= 1;
				y += 1;
				break;
			case 2:
				x -= 1;
				break;
			case 3:
				x -= 1;
				y -= 1;
				break;
			case 4:
				y -= 1;
				break;
			case 5:
				x += 1;
				y -= 1;
				break;
			case 6:
				x += 1;
				break;
			case 7:
				x += 1;
				y += 1;
				break;
			default:
				return;
		}
		writeC(Opcodes.S_OPCODE_MOVEOBJECT);
		writeD(cha.get_objectId());
		writeH(x);
		writeH(y);
		writeC(cha.get_heading());
	}

	public byte[] send(){
		
		return getBytes();
	}
}